#include<bits/stdc++.h>
using namespace std;
int mx[1005][1005];
int mx2[1005][1005];
int dx[] = {1,-1,0};
int dy[] = {1,-1,0};
int vis[1005][1005];
int n;
int f;
int check(int x,int y){
    //上下左右都是岛
    if(mx[x - 1][y] && mx[x + 1][y] && mx[x][y - 1] && mx[x][y + 1]){
        return 1;
    }
    return 0;
}
int dfs(int x,int y){
    
    if(!vis[x][y]) f += check(x,y);
    vis[x][y] = 1;
    if(x <= 0 || y <= 0 || x > n || y > n || mx2[x][y] == 0){
        return 0;
    }
    mx2[x][y] = 0;
    return 1 + dfs(x - 1,y) + dfs(x + 1,y) + dfs(x,y + 1) + dfs(x,y - 1);
}
int main(){

    cin >> n;
    for(int i = 1;i <= n;i++){
        for(int j = 1;j <= n;j++){
            char c;
            cin >> c;
            if(c == '.') mx[i][j] = 0;
            else mx[i][j] = 1;
            mx2[i][j] = mx[i][j];
        }
    }
    int cnt = 0;
    int cnt2 = 0;
    for(int i = 1;i <= n;i++){
        for(int j = 1;j <= n;j++){
            if(dfs(i,j) > 0){
                cnt++;
                if(f){
                    f = 0;
                    cnt2++;
                }
            }
        }
    }
    cout << cnt - cnt2 << "\n";
}